package util;

import java.util.Date;

import com.huawei.api.SMEntry; 
import com.huawei.api.SMException;
import com.huawei.api.smsend.system.SMLog;

public class smsIn {
	public static String sourceAddr = "106573160105";
	public static int  needStateReport = 1;
	public static String ServiceID = "MSD2110101";
	public static String feeType = "01";
	public static String feeCode = "0";

    // 数据库登陆参数
	public static String DB_IP = "218.201.155.112";
	public static String DB_UserName = "CustomSMS";  
	public static String DB_PWord = "SqlMsde@InfoxEie2000"; 

    // MAS登陆参数
	public static String MAS_UserName = "admin";
	public static String MAS_PWord = "y4yhl9t";
	public void initsmsIn(){
		 try
	       {
	           SMEntry.init(DB_IP, DB_UserName, DB_PWord);
	           SMEntry.logIn(MAS_UserName, MAS_PWord);
	       }
	       catch (SMException ex)
	       {
	           //SMLog.fatal(ex.getErrorDesc(),ex);
	           System.out.println("初始化TTTTTTTTTTTTTTTTTTTTTTT异常出现!!!!");
	       }
	}
	 private static int test_SendShortMessage(String PhoneNomber, String Content,Date date)
	    {
		 System.out.println("发送开始");
	        Date atTime = date;//Timestamp.valueOf("2011-03-07 15:46:13");
	       
	        try
	        {
	             int num =  SMEntry.submitShortMessageState(atTime, sourceAddr
	                                            , PhoneNomber, Content
	                                            , needStateReport,
	                                            ServiceID, feeType, feeCode);
	             System.out.println("返回唯一标识="+num);
	        	Thread.sleep(Long.parseLong("300"));
	             if(num>0){
	            	 System.out.println("发送成功!!!");
	             }else{
	            	 System.out.println("发送众失败!!!");
	             }
	             return num;
	        }
	        catch (Exception ex)
	        {
	            SMLog.error("submit sms failed.",ex);
	            System.out.println("发送时出现异常$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
	            return 0;
	        }
	    }
	 public String returnLogo(String phone,String content,Date date){
			System.out.println("进入！！！");
			 initsmsIn();
			 int num = test_SendShortMessage(phone,content,date);
			 return String.valueOf(num);
		}
	 public static void main(String args[]){
	 }
}
